package engine.newUi
{
	import com.greensock.TweenLite;
	import com.greensock.easing.Linear;
	
	import engine.control.loading.MultLoader;
	import engine.data.BindManage;
	import engine.data.ModelLocator;
	import engine.data.ObjectData;
	import engine.data.ResPath;
	import engine.data.Scene;
	import engine.data.View;
	import engine.data.ViewObject;
	import engine.flag.GameDefine;
	import engine.flag.PlayerActionFlag;
	import engine.flag.ResourcesPath;
	import engine.logic.DieHelpLogic;
	import engine.logic.event.LogicEvent;
	import engine.logic.login.NxCallLater;
	import engine.logic.walk.WalkManager;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.scene.SceneManager;
	import engine.scene.player.MoveAction;
	import engine.tip.TipsMainLogic;
	import engine.tip.tipItem.BookKungfuItem;
	import engine.util.FilterUtil;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Shape;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.text.TextField;
	import flash.ui.Mouse;
	
	import mx.resources.ResourceManager;
	
	import newx.StageInfo;
	import newx.com.ResManager;
	import newx.com.config.StaticIni;
	import newx.com.control.NxClip;
	import newx.com.control.button.NxButton;
	import newx.com.control.group.NxViewGroup;
	import newx.com.control.text.NxLabel;
	import newx.com.control.text.NxText;
	import newx.com.control.window.NxWindowEvent;
	import newx.com.loader.SwfLoader;

	/**
	 *伙伴招募 
	 * @author yangyuechao
	 * 
	 */	
	public class PartnerRequestNewLogic
	{
		private static var _self:PartnerRequestNewLogic;
		private var _myDis:PartnerRequestNewUI;
		private var _bind:BindManage;
		private var _model:ModelLocator;
		private var _tip:TipsMainLogic;
		
		private var _bindInitFlag:Boolean	= false;
		/**伙伴视图**/
		private var _bindViewFlag:int		= -1;
		/**声望**/
		private var _bindReputeFlag:int	= -1;
		/**铜钱**/
		private var _bindGoldFlag:int		= -1;
			
		/**
		 *第一个伙伴ID 
		 */		
		private var _firstPartnerId:int	= 21001057;
		/**
		 *MAX_LEN_PER_REC	每单元最大三个格子 
		 * MAX_LEN_PER_REC	每页最小格子数
		 * HERO_COUNT		英雄格子数
		 */		
		private const MAX_LEN_PER_REC:int	= 3,
			MIN_PER_PAGE:int				= 2,
			HERO_COUNT:int					= 3;
		
		/**
		 *界面蒙版 
		 */		
		private var _winmask:Shape			= new Shape();
		/**
		 *普通伙伴蒙版 
		 */		
		private var _groupmask:Shape		= new Shape();
		/**
		 *属性面板 
		 */		
		private var _proPanel:NxClip		= new NxClip;
		/**
		 *对话面板
		 */		
		private var _talkPanel:NxClip		= new NxClip;
		/**
		 *人物初始坐标 
		 */		
		private const _actorInitPoint:Point	= new Point(50, 435);
		/**
		 *人物移动至的坐标 
		 */		
		private const _actorPoint:Point	= new Point(500, 435);
		/**
		 *属性面板初始坐标 
		 */		
		private const _proSpPoint:Point	= new Point(937, 235);
		/**
		 *属性面板移动至的坐标 
		 */		
		private const _proAimPoint:Point	= new Point(690, 235);
		/**
		 *会话面板初始坐标 
		 */		
		private const _talkPanelPoint:Point	= new Point(-48, 235);
		/**
		 *会话面板移动至的坐标 
		 */		
		private const _talkAimPoint:Point		= new Point(90, 235);
		
		private const _proPointArr:Array		= new Array({x:55, y:44},//生命
															{x:55, y:59},//外功
															{x:55, y:74},//内功
															{x:55, y:90});//体魄
		
		//============================================================
		/**
		 * 		PART_NAME	伙伴名字   
		 *		PART_GANG	伙伴门派
		 *		PART_TASK	主线任务需求
		 *		PART_MONEY	货币需求
		 * 		PART_NEED_LEVEL 伙伴邀请等级(也是声望等级)
		 * 		PART_HEAD	伙伴头像
		 * 		PART_COMMEND	是否推荐（1,0）
		 * 		PART_HALF	半身像
		 * 		PART_CONFIG_ID	id
		 * 		PART_SKILL:String	技能
		 *		PART_SKILL_DES:		技能描述
		 *		PART_HP:String		生命
		 *		PART_MAXHP:String	,最大生命
		 *		PART_ING:String		内功
		 *		PART_STA:String		体质
		 *		PART_STR:String		外功
		 * 		PART_PEER:String	声望
		 * 		PART_LEVEL:String		等级
		 */
		private const PART_NAME:String		=	"nname",
			PART_GANG:String	=	"ProfType",
			PART_MONEY:String	=	"NeedGoldCoin",
			PART_HEAD:String	=	"Model",
			PART_COMMEND:String	=	"NeedRecommend",
			PART_HALF:String	=	"Model",
			PART_SKILL:String	=	"DefaultUltraSkill",
			PART_SKILL_DES:String	=	"skill_dest",
			PART_HP:String		=	"HP",
			PART_MAXHP:String	=	"MaxHP",
			PART_ING:String		=	"Ing",
			PART_STA:String		=	"Sta",
			PART_STR:String		=	"Str",
			PART_LEVEL:String	=	ActorPropertyUI.LEVEL;
		public static const 		PART_NEED_LEVEL:String	=	"PartnerInviteLevel",
			PART_TASK:String	=	"NeedTaskID",
			PART_PEER:String	=	"NeedRepute",
			PART_CONFIG_ID:String	=	"ConfigID";
		
		private const MAINMC:String = "p_mc_";
		private const MC_DATA:String	="mc_data";
		private const MC_PIC:String	="mc_pic";
		
		private const NAME:String	=	"titleTxt";
		private const ICON:String	=	"lvIcon";
		private const LVL:String	=	"infoTxt";
		
		/**
		 * 邀请
		 *	归队
		 * 字符串 
		 */		
		private const APPLY_STR:String	=	"UIString_1000574",
			COME_BACK_STR:String	="UIString_1000024";
		
		private const APPLY_BTN:String	= "Button_51",
			COME_BACK_BTN:String	= "Button_55";
		
		private const PRO_BASE_VALUE:int = 1000;
		
		//==========================================================
		/**
		 *储存所有伙伴 
		 */		
		private var _partnerALL:Object;
		/**
		 *储存英雄榜伙伴 
		 */		
		private var _heroPartner:Object;
		/**
		 *当前选择招募的ID 
		 */		
		private var _currSelectConfigID:int;
		/**
		 *储存当前所需要显示的level 
		 */		
		private var _partnerLevelShow:Array	= [];
		/**
		 *是否遍历声望 
		 */		
		private var _hasPartnerInvite:Boolean	= false;
		/**
		 *当前选中的 
		 */		
		private var _clickMcData:Object;
		/**
		 *是否播放人物模型中 
		 */		
		private var _rolePlayBol:Boolean		= false;
		/**
		 *是否在框框移动中 
		 */		
		private var _moveBol:Boolean			= false;
		/**
		 *点击的是否为英雄伙伴 
		 */		
		private var _heroClickBol:Boolean		= false;
		/**
		 *总页数 
		 */		
		private var _allPage:int				= 0;
		/**
		 *当前页数 
		 */		
		private var _pageNow:int				= 1;
		/**
		 *是否在移动group中 
		 */		
		private var _moveGroupBol:Boolean		= false;
		/**
		 *是否需要排序 
		 */		
		private var _isSort:Boolean			= false;
		/**
		 *鼠标点击坐标 
		 */		
		private var _mouseClickPoint:Point		= new Point(0,0);
		/**
		 *鼠标移动坐标 
		 */		
		private var _mouseMovePoint:Point		= new Point(0,0);
		/**
		 *移动方向 
		 */		
		private var dircetion:Boolean			= false;
		/**
		 *当页起始点 
		 */		
		private var _pageNowX:Number			= 0;
		/**
		 *上一次点击头像 
		 */		
		private var _preHeadMc:MovieClip		= new MovieClip;
		/**
		 *默认皮肤 
		 */		
		private var _defaultSkin:MovieClip		= new MovieClip;
		/**
		 *是否拥有第一个伙伴
		 */		
		private var _isHasFirst:Boolean;
		/**
		 *是否今日第一次打开 
		 */		
		private var _isOpenFirst:Boolean;
		/**
		 *是否是归队伙伴 
		 */		
		private var _isComeBack:Boolean;
		/**
		 *是否打开过界面 
		 */		
		private var _isOpened:Boolean;
		
		public function PartnerRequestNewLogic()
		{
			_myDis	= PartnerRequestNewUI.getInstance();
			_bind	= BindManage.getInstance();
			_model	= ModelLocator.getInstance();
			_tip	= TipsMainLogic.instance;
		}
		
		public static function getInstance():PartnerRequestNewLogic
		{
			if(_self == null){
				_self = new PartnerRequestNewLogic();
			}
			return _self;
		}
		
		/**
		 *初始化部分 
		 * 
		 */		
		public function Init():void
		{	
			_isOpenFirst	= true;
			_isOpened		= false;
		}
		
		public function beforeShow():void
		{
			_isSort			= false;
			_partnerLevelShow	= [];
			if(!SceneManager._itemIconLoad)
			{
				_model.addEventListener(LogicEvent.ITEMICONLOADED,loaded);
				function loaded():void
				{
					if(!_myDis.created) return;
					updataALl();
					_model.removeEventListener(LogicEvent.ITEMICONLOADED,loaded)
				}
			}
			_bindInitFlag	= true;
			
			if(!_isOpened)
			{
				var mc:MovieClip = MultLoader.getInstance().getSourceByUrl(ResPath.SWF + "partnerRequest.swf");
				ResManager.SaveRes("partner", mc);
				_myDis.bg.source	= ResManager.newResClass("Partner_Bg") as MovieClip;
				_proPanel.source	= ResManager.newResClass("Partner_ProBg") as MovieClip;
				_talkPanel.source	= ResManager.newResClass("Partner_ProBg") as MovieClip;
				
				_partnerALL = {};
				_heroPartner = {};
				ransackConfig();
				initAccept();
				
				//隐藏伙伴属性面板和招募按钮
				_myDis.sendBtn.visible		= false;
				
				_proPanel.x					= _proSpPoint.x;
				_proPanel.y					= _proSpPoint.y;
				_proPanel.visible			= false;
				_myDis.windowBG.addChild(_proPanel);
				
				//会话面板
				_talkPanel.x				= _talkPanelPoint.x;
				_talkPanel.y				= _talkPanelPoint.y;
				_talkPanel.visible			= false;
				_myDis.windowBG.addChild(_talkPanel);
				
				//界面遮罩
				_winmask.graphics.beginFill(0xFF8800);
				_winmask.graphics.drawRect(5, 0, _myDis.windowBG.width - 10, _myDis.windowBG.height);
				_winmask.graphics.endFill();
				_myDis.windowBG.addChild(_winmask);
				_myDis.windowBG.mask		= _winmask;
				_winmask.visible 	= false;
				
				//普通伙伴遮罩
				_groupmask.graphics.beginFill(0xFF8800);
				_groupmask.graphics.drawRect(125, 481, 660, 100);
				_groupmask.graphics.endFill();
				_myDis.windowBG.addChild(_groupmask);
				_myDis.mainGroup.mask	= _groupmask;
				_groupmask.visible 	= false;
				
				_isOpened = true;
			}
			resetReputeLevel()
			ransackPartner();
			ransackRetire();
			//获取玩家是否拥有第一个伙伴
			_isHasFirst	= (getPartnerStatues(_firstPartnerId) == 0) ? true : false;
			updataALl();
			
			addEventListener();
			bind();
		}
		
		/**
		 *各种侦听添加 
		 * 
		 */		
		private function addEventListener():void
		{
			_myDis.windowBG.addEventListener(NxWindowEvent.WINDOW_CLOSE, closeHandler);
			
			_myDis.mainGroup.addItemsEvent(MouseEvent.CLICK, clickHandle);
//			_myDis.mainGroup.addItemsEvent(MouseEvent.MOUSE_OVER, rollOver);
//			_myDis.mainGroup.addItemsEvent(MouseEvent.MOUSE_OUT, rollOut);
			
			_myDis.heroGroup.addItemsEvent(MouseEvent.CLICK, clickHandle);
//			_myDis.heroGroup.addItemsEvent(MouseEvent.ROLL_OVER, rollOver);
//			_myDis.heroGroup.addItemsEvent(MouseEvent.ROLL_OUT, rollOut);
			
			_myDis.sendBtn.addEventListener(MouseEvent.CLICK, clickHandle);
			
			_myDis.actorClip.addEventListener(MouseEvent.CLICK, actorClick);
			
			_myDis.preBtn.addEventListener(MouseEvent.CLICK, preBtnHandler);
			_myDis.nexBtn.addEventListener(MouseEvent.CLICK, nexBtnHandler);
			
			_myDis.mainGroup.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
		}
		
		/**
		 *各种属性绑定 
		 * 
		 */		
		private function bind():void
		{
			if(_bindViewFlag == -1 )
			{
				_bindViewFlag		=	_bind.BindView(_model.scene, View.VIEWPORT_PARTNER, OnAddPartner, OnRemovePartner);
			}
			if(_bindGoldFlag == -1)
			{
				_bindGoldFlag		=	_bind.BindProp(_model.scene.Role, "GoldCoin", this, "money");			
			}
			if(_bindReputeFlag == -1)
			{
				_bindReputeFlag		=	_bind.BindProp(_model.scene.Role, "Repute", this, "repute");				
			}
		}
		
		public function afterHide():void
		{
			_bindInitFlag		= false;
			_partnerLevelShow	= [];
			removeEventListener();
			unBind();
			clear();
			_currSelectConfigID =0;
		}
		
		/**
		 *各种侦听删除 
		 * 
		 */		
		private function removeEventListener():void
		{
			_myDis.windowBG.removeEventListener(NxWindowEvent.WINDOW_CLOSE, closeHandler);
			
			_myDis.mainGroup.removeItemsEvent(MouseEvent.CLICK, clickHandle);
//			_myDis.mainGroup.removeItemsEvent(MouseEvent.ROLL_OVER, rollOver);
//			_myDis.mainGroup.removeItemsEvent(MouseEvent.ROLL_OUT, rollOut);
			
			_myDis.heroGroup.removeItemsEvent(MouseEvent.CLICK, clickHandle);
//			_myDis.heroGroup.removeItemsEvent(MouseEvent.ROLL_OVER, rollOver);
//			_myDis.heroGroup.removeItemsEvent(MouseEvent.ROLL_OUT, rollOut);
			
			_myDis.sendBtn.removeEventListener(MouseEvent.CLICK, clickHandle);
			
			_myDis.preBtn.removeEventListener(MouseEvent.CLICK, preBtnHandler);
			_myDis.nexBtn.removeEventListener(MouseEvent.CLICK, nexBtnHandler);
			
			if(_myDis.actorClip.hasEventListener(MouseEvent.CLICK)){
				_myDis.actorClip.removeEventListener(MouseEvent.CLICK, actorClick);
			}
			
			_myDis.mainGroup.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
		}
		
		/**
		 *各种绑定移除 
		 * 
		 */		
		private function unBind():void
		{
			if(_bindViewFlag != -1 )
			{
				_bindViewFlag		=	_bind.UnbindView(View.VIEWPORT_PARTNER, _bindViewFlag);
			}
			if(_bindGoldFlag != -1)
			{
				_bindGoldFlag		=	_bind.UnbindProp(_model.scene.Role, "GoldCoin", _bindGoldFlag);				
			}
			if(_bindReputeFlag != -1)
			{
				_bindReputeFlag		=	_bind.UnbindProp(_model.scene.Role, "Repute", _bindReputeFlag);				
			}
		}
		
		/**
		 *关闭界面 
		 * @param e
		 * 
		 */		
		private function closeHandler(e:NxWindowEvent):void
		{
			_myDis.hide();
		}
		
		/**
		 *清空必要清空 
		 * 
		 */		
		private function clear():void
		{
			for each (var i:PartnerGroup in _partnerALL) 
			{
				i.resetServerdata();
			}
			for each (i in _heroPartner) 
			{
				i.resetServerdata();
			}
		}
		
		private function initAccept():void
		{
			var _currentAcceptTable:Object		= PartnerGroup.CurrentAcceptTable;
			var _currentAcceptPartner:Object	= PartnerGroup.CurrentAcceptPartner;
			if(_currentAcceptTable) return;
			_currentAcceptTable					= StaticIni.getIniObj("PartnerInvite_SPecial");
			for (var i:String in _currentAcceptTable) 
			{
				_currentAcceptPartner[_currentAcceptTable[i]]	= i;
			}
			
		}
		
		/**
		 *遍历 伙伴配置 (伙伴)
		 *这个只需要初始化 遍历一次
		 * 
		 */		
		private function ransackConfig():void
		{
			//资源域名前缀
			const PARTNER:String	= "21001001"
			var tArr:Object;
			var i:int				= int(PARTNER);
			do
			{
				tArr	= getPartnerInfo(i);
				i++;
				setPartner(tArr);
			}while(tArr != null)
		}
		
		/**
		 *读取伙伴本地配置 
		 * @param id
		 * @return 
		 * 
		 */		
		private function getPartnerInfo(id:int):Object
		{
			var obj:*	= _tip.getStaticObjWithID(String(id));
			if(obj)
			{
				obj[PART_CONFIG_ID]	= id;
//				obj[PART_MAXHP]		= GameDefine.GET_MAXHP(obj[PART_STA], obj[PART_LEVEL]);
			}
			return obj;
		}
		
		/**
		 * 写文件设置
		 * @param arr			 
		 * @see getPartnerInfo
		 */		
		private function setPartner(arr:Object):void
		{
			if(arr)
			{
				var level:int			= arr[PART_NEED_LEVEL];
				//如果是英雄伙伴则另外存储
				if(arr.hasOwnProperty("Hero")){
					var group:PartnerGroup	= _heroPartner[arr[PART_PEER]];
					if(!group)
					{
						_heroPartner[arr[PART_PEER]]	= group	= new PartnerGroup(level);
					}
					group.addConfigPartner(arr);
				}
				group	= _partnerALL[level];
				if(!group)
				{
					_partnerALL[level]	= group	= new PartnerGroup(level);
				}
				group.addConfigPartner(arr);
			}
		}
		
		/**
		 *对比声望等级 
		 * 
		 */		
		private function resetReputeLevel():void
		{
			var reputeLevel:int	= _model.scene.Role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE);
			for  (var i:String in _partnerALL) 
			{
				if(_partnerALL[i].useAble)
				{
					_partnerLevelShow.push(int(i));
				}
			}
		}
		
		/**
		 **根据等级获得改等级的可邀请伙伴 
		 * @param level
		 * @return 
		 * 
		 */
		public function getPartnerByLevel(level : int):Object
		{
			if(_partnerALL == null)
			{
				_partnerALL	= {};
				_heroPartner = {};
				ransackConfig();
			}
			if(level > 10)
			{
				return null;
			}
			var obj:Object = _partnerALL[level];
			return obj;
		}
		
		/**
		 *遍历玩家伙伴 
		 * 
		 */		
		private function ransackPartner():void
		{
			var view:View	= _model.scene.GetView(View.VIEWPORT_PARTNER);
			view.getDataForEach(function (key:Object,value:Object):void
			{
				var viewobj:ViewObject	= value as ViewObject;
				if(viewobj)
				{
					viewobj.HandleProperties("isFull",false);
					var level:int	= PartnerGroup.getLevel(viewobj);
					_partnerALL[level].addViewPartner(viewobj);
				}
			}
			)
		}
		/**
		 * 遍历离队伙伴 
		 * 
		 */		
		private function ransackRetire():void
		{
			var view:View	= _model.scene.GetView(View.VIEWPORT_RETIRE_PARTNER);
			view.getDataForEach(function (key:Object,value:Object):void
			{
				var viewobj:ViewObject	= value as ViewObject
				if(viewobj)
				{
					viewobj.HandleProperties("isFull",true);
					var level:int	= PartnerGroup.getLevel(viewobj);
					_partnerALL[level].addRetirePartner(viewobj);
				}
			}
			)
		}
		
		/**
		 *数据准备完毕 后 刷新显示 
		 * 
		 */		
		private function updataALl():void
		{
			_hasPartnerInvite = false;
			//遍历声望
			var len:int			= _myDis.mainGroup.col	= Math.max(_partnerLevelShow.length, MIN_PER_PAGE);
//			_allPage			= int(Math.ceil(len / 2));
			_allPage			= len - 1;
			_pageNow			= _allPage;
			_myDis.pageLab.htmlText	= _pageNow + "/" + _allPage;
			setLeftRightBtn();
//			_myDis.mainGroup.mouseEnabled	= false;
			if(!_isSort){
				sortShowLevelArr();
			}
			for (var i:int = 0; i < len; i++) 
			{
				var mc:MovieClip	= _myDis.mainGroup.getItemByIndex(i);
				var level:int		= _partnerLevelShow[i];
				if(level >= 0)
				{
					var needLv:int	= int(StaticIni.getIniVar("PartnerGradeNeedLevel","PartnerGradeNeedLevel_"+_partnerALL[level]["Level"]));
					var roleLv:int	= ModelLocator.getInstance().scene.Role.getPlayerLevel();
					updateSingle(_partnerALL[level], mc);
				}
				else
				{
					showDisable(mc, 2);
				}
			}
			updateHero();
			
			//设置到最后一页
			_pageNowX	= _myDis.mainGroup.x = (_allPage == 1) ? 125 : 125 - 330 * (_allPage - 1);
			
			//获取当前能招的，推荐的优先
			var _tempZhaomu:int = (_partnerALL[len - 1].getShowPartners() as Array).length;
			var _curZhaomu:Array = (_tempZhaomu == 0) ? _partnerALL[len].getShowPartners() : _partnerALL[len - 1].getShowPartners();
			var _zhaomuIndex:int = (_isHasFirst && _isOpenFirst) ? 0 : checkWhoCanShow(_curZhaomu);
			var _tempMc:int		 = (_tempZhaomu == 0) ? (len - 1) : (len - 2);
			var _zhaomuMc:int	 = (_isHasFirst && _isOpenFirst) ? 0 : _tempMc;
			//默认当前能招的站中间
//			if(_isHasFirst && _isOpenFirst) {
				mc					= _myDis.mainGroup.getItemByIndex(_zhaomuMc) as MovieClip;
				var m:MovieClip		= new MovieClip;
				var data:Object		= {};
				_heroClickBol		= false;
				m	= getHeadByIndex(mc, _zhaomuIndex);
				if(!m)	return;
				var index:int		= int(m.name.charAt(m.name.length - 1));
				data				= mc[MC_DATA][index];
				if(data == null) return;
				m.gotoAndStop(2);
				_preHeadMc					= m;
				_clickMcData				= data;
				rightData					= data;
				actorHalf					= data;
				_myDis.actorClip.source		= null;
				_myDis.actorClip.source 	= ResManager.newResClass( "custSkin_86" ) as MovieClip;
				var urlStr:String = "";
				//加载人物模型
				if(data.hasOwnProperty(PART_HEAD))
				{
					urlStr = ResPath.ACTORS + "npc_" + data[ActorPropertyUI.MODEL] + ".swf";
				}
				else
				{
					urlStr = ResourcesPath.getModel(data as ObjectData);
				}
				SwfLoader.StartLoad(urlStr, null, loadOver);
				function loadOver(mc:DisplayObject,pList:Array):void
				{
					_myDis.actorClip.source	= mc;
				}
				_myDis.sendBtn.visible		= true;
				_myDis.actorClip.x			= _actorPoint.x;
				_myDis.actorClip.y			= _actorPoint.y;
				_proPanel.x					= _proAimPoint.x;
				_proPanel.y					= _proAimPoint.y;
				_proPanel.visible			= true;
				_talkPanel.x				= _talkAimPoint.x;
				_talkPanel.y				= _talkAimPoint.y;
				_talkPanel.visible			= true;
				_myDis.actorClip.addLoadedEvent(
					function loadOver():void
					{
						actorClick(null);
					},Event.COMPLETE);
				_myDis.actorClip.mouseChildren 	= _myDis.actorClip.mouseEnabled = _myDis.actorClip.buttonMode = true;
				_myDis.sendBtn.mouseEnabled	= false;
				_myDis.sendBtn.skin		= APPLY_BTN;
				btnEnable(data);
//			}
			
			function btnEnable():void
			{
				var errStr:String	= applyCondition(data);
				if(!errStr)
				{
					_myDis.sendBtn.enabled	= true;
					_myDis.sendBtn.filters	= [];
				}
				else
				{
					_myDis.sendBtn.enabled	= false;
					_myDis.sendBtn.filters	= [FilterUtil.GrayColorFilter];
				}
			}
			
			/**
			 *能否申请 
			 * @return 
			 * 
			 */		
			function applyCondition(arr:Object):String
			{
				if(arr is ViewObject) return "";
				var moneyNeed:int	=	arr[PART_MONEY]
				if(arr[PART_PEER] > _model.scene.Role.GetPropertiesEx("Repute")){
					return PART_PEER;
				}
				if(moneyNeed >	_model.scene.Role.getGoldCoin()){
					return PART_MONEY;
				}
				if(arr[PART_NEED_LEVEL] > _model.scene.Role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE)){
					return PART_NEED_LEVEL;
				}	
				return "";
			}
			
			//返回一个可招募的人
			function checkWhoCanShow(_zhaomuArr:Array):int
			{
				var _return:int = -1;
				for(var j:String in _zhaomuArr){
					if(_zhaomuArr[j] is ViewObject) {
						_zhaomuArr.splice(j);
						continue;
					}
					_zhaomuArr[j]["index"] = int(j);
				}
				var _newArr:Array = (_zhaomuArr.sortOn(PART_COMMEND, Array.NUMERIC) as Array).reverse();
				for(j in _newArr)
				{
					if(_newArr[j]["isFull"])
					{
						var _isRecommend:int = int(_newArr[j][PART_COMMEND]);
						var _nameID:int		= _newArr[j]["NameID"];
						var _isHas:int = getPartnerStatues(_nameID);
						if(_isRecommend == 1)//要推荐 看有没有这人
						{
							if(_isHas == 0){	//未招募
								_return = _newArr[j]["index"];
								return _return;
							} else {
								continue;
							}
						} else //不推荐 看看 
						{
							if(_isHas == 0){	//未招募
								_return =  _newArr[j]["index"];
								return _return;
							} else {
								continue;
							}
						}
					} else {
						continue;
					}
				}
				return _return;
			}
		}
		
		/**
		 *英雄伙伴 
		 * 
		 */		
		private function updateHero():void
		{
			var _indexArr:Array = new Array();
			//按照声望排序
			for(var j:String in _heroPartner)
			{
				_indexArr.push(int(j));
			}
			_indexArr.sort(Array.NUMERIC);	
			for(var i:int = 0; i < HERO_COUNT; i++)
			{
				var _heroMc:MovieClip = _myDis.heroGroup.getItemByIndex(i);
				var obj:*		= getShowHero(_heroPartner[_indexArr[i]]);
				var img:NxClip 	= new NxClip;
				img.x			= 0;
				img.y			= 0;
				img.buttonMode	= true;
				_heroMc.addChild(img);
				_heroMc["yzm"].visible	= false;
				_heroMc[MC_DATA] = obj;
				var imgSource:int		= 0;
				var name:String			= "";
				var level:int			= 0;
				//已经招募过
				if(obj is ViewObject){
					imgSource	= (obj as ViewObject).GetProperties(PART_HEAD);
					name		= (obj as ViewObject).GetProperties(PART_CONFIG_ID);
					level		= (obj as ViewObject).GetProperties(PART_LEVEL);
				} else {
					imgSource	= PartnerGroup.getPropertyIn(obj, PART_HEAD);
					name		= PartnerGroup.getPropertyIn(obj, PART_CONFIG_ID);
					level		= PartnerGroup.getPropertyIn(obj, PART_LEVEL);
				}
				var heroState:int	= getHeroStatues(int(name));
				if(heroState == 1){
					_heroMc["yzm"].visible	= true;
				} else {
					_heroMc["yzm"].visible	= false;
				}
				
				img.source		= ResourcesPath.getMiniHeadPic(imgSource);
				_heroMc["face"].addChild(img);
				(_heroMc[NAME] as TextField).htmlText	= StaticIni.getSwfLangStrVar("PlayerProperty_20",[StaticIni.getSwfLangStr(name)]);
				(_heroMc[LVL] as TextField).htmlText	= StaticIni.getSwfLangStrVar("PlayerProperty_19",[level]);
			}
		}
		
		/**
		 *得到英雄显示数组 
		 * @return 
		 * 
		 */	
		private function getShowHero(obj:PartnerGroup):*
		{
			var arr:Array		= [];
			for each (var i:Object in obj.partnerVecor) 
			{
				arr.push(i);
			}
			return arr[0];
		}
		
		/**
		 *按照降序排序 
		 * 
		 */		
		private function sortShowLevelArr():void
		{
			_partnerLevelShow.sort(Array.NUMERIC);
			if(_partnerLevelShow.length	< MIN_PER_PAGE)
			{
				var len:int		= _partnerLevelShow.length;
				for (var i:int = 0; i < MIN_PER_PAGE - len; i++)
				{
					_partnerLevelShow.push(-1);
				}
			}
			_isSort	= true;
		}
		
		/**
		 *更新单个 
		 * @param data
		 * @param mc
		 * 
		 */		
		private function updateSingle(_data:PartnerGroup,mc:MovieClip):void
		{
			if(!_data || !mc)	return;
			var showArr:Array	= _data.getShowPartners();
			var len:int			= showArr.length;
			mc[MC_DATA]			= showArr;
			for (var i:int = 0; i < MAX_LEN_PER_REC	; i++) 
			{
				var m:MovieClip	= getHeadByIndex(mc, i);
				
				if(requireLevel()&& i<len)
				{
					var d:Object	= showArr[i];
					if(!d)continue;
					var isFull:Boolean = (d is ViewObject)?(d as ViewObject).GetProperties("isFull"):d["isFull"];
					if(isFull)
					{
						
						if(m["comand"])
						{
							(m["comand"] as NxClip).source = PartnerGroup.getPropertyIn(d, PART_COMMEND) ? "" : "";
						}
						m.visible		= true;
						m.buttonMode	= true;
						m.gotoAndStop(1);
						if(_clickMcData && d == _clickMcData){
							m.gotoAndStop(2);
						}
						pic(PartnerGroup.getPropertyIn(d, PART_HEAD),
							PartnerGroup.getPropertyIn(d,PART_COMMEND),
							PartnerGroup.getPropertyIn(d,PART_NEED_LEVEL));
						name(PartnerGroup.getPropertyIn(d,PART_CONFIG_ID));
						level(PartnerGroup.getPropertyIn(d,PART_LEVEL));
						var needGoldCoin:int	= PartnerGroup.getPropertyIn(d,PART_MONEY);
						var goldcoin:int		= _model.scene.Role.getGoldCoin();
						var needRepute:int		= PartnerGroup.getPropertyIn(d,PART_PEER);
						var repute:int			= _model.scene.Role.GetProperties("NeedRepute");
						if( needGoldCoin <= goldcoin && needRepute <= repute){
							_hasPartnerInvite	= true;
						}
					}
					else
					{
						//获取普通伙伴状态   未招募， 已招募， 离队
						var partnerStatues:int	= getPartnerStatues(PartnerGroup.getPropertyIn(d, PART_CONFIG_ID));
						{
							if(partnerStatues == 1){
								m.visible			= false;
							} else if(partnerStatues == 0){
								if(m[MC_PIC]){
									m[MC_PIC].source = null;
								}
								m[NAME].htmlText	= StaticIni.getSwfLangStrVar("PlayerProperty_20",[StaticIni.getSwfLangStr("UIString_1000714")]);
								m[LVL].htmlText		= StaticIni.getSwfLangStr("UIString_1000715");
								m.gotoAndStop(1);
							}
						}
					}
				}
				else
				{
					m.visible	= false;
				}
			}
			mc["txt"].visible	= !len;
			
			var strID:String;
			var selfLv:int	= int(_model.scene.Role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE));
			if(_data.Level > selfLv)  //设置高于自己的
			{
				strID	= "UIString_1000571";  //尚未到达
			}
			else   //低于自己的
			{
				
				var partnerVo:View	= _model.scene.GetView(View.VIEWPORT_PARTNER);
				strID	= check(_data.Level) ? "UIString_1000572" : "UIString_1000571";
			}
			mc["txt"].htmlText	= StaticIni.getSwfLangStr(strID);
			
			//帧数与等级的过滤
			function requireLevel():Boolean
			{
				var b:Boolean	= _data.Level <= mc[ICON].totalFrames;
				mc[ICON].gotoAndStop(_data.Level);
				return b;
			}
			function pic(configid:int,part_comment:int,partnerNeedLevel:int):void
			{
				if(!m[MC_PIC])
				{
					m[MC_PIC]	= new NxClip;
					m["face"].addChild(m[MC_PIC]);
					if(part_comment == 1 && partnerNeedLevel >= int(_model.scene.Role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE)))
					{
						var commend_Pic:NxClip	= new NxClip();
						commend_Pic.x			= -5;
						commend_Pic.y			= -5;
						commend_Pic.source		= ResManager.newResClass("CustomControl_0119");
						m["face"].addChild(commend_Pic);
					}
				}
				m[MC_PIC].source	= ResourcesPath.getMiniHeadPic(configid);
			}
			function name(configid:String):void
			{
				m[NAME].htmlText	= StaticIni.getSwfLangStrVar("PlayerProperty_20",[StaticIni.getSwfLangStr(configid)]);
			}
			function level(str:String):void
			{
				m[LVL].htmlText	= StaticIni.getSwfLangStrVar("PlayerProperty_19",[str]);
			}
		}
		
		/**
		 *获取普通伙伴状态 
		 * @param configID
		 * @return 
		 * 未招募， 已招募， 离队
		 */		
		private function getPartnerStatues(configID:int):int
		{
			var state:int = 0;
			var view:View	= _model.scene.GetView(View.VIEWPORT_PARTNER);
			view.getDataForEach(function (key:Object,value:Object):void
			{
				var viewobj:ViewObject	= value as ViewObject;
				if(viewobj && viewobj.GetProperties(PART_CONFIG_ID) == configID)
				{
					var Level:int	= PartnerGroup.getLevel(viewobj);
					state = 1;
				}
			}
			)
			
			view	= _model.scene.GetView(View.VIEWPORT_RETIRE_PARTNER);
			view.getDataForEach(function (key:Object,value:Object):void
			{
				var viewobj:ViewObject	= value as ViewObject
				if(viewobj && viewobj.GetProperties(PART_CONFIG_ID) == configID)
				{
					var Level:int	= PartnerGroup.getLevel(viewobj);
					state = 2;
				}
			}
			)
			return state;
		}
		
		private function getHeadByIndex(mc:MovieClip,index:int):MovieClip
		{
			return mc[MAINMC + index];
		}
		
		/**
		 *检查是招募完 还是未满足 
		 * @param lv
		 * @return 
		 * 
		 */		
		private function check(lv:int):Boolean
		{
			
			var partnerVo:View	= _model.scene.GetView(View.VIEWPORT_PARTNER);
			if(_partnerALL[lv] == null) return true;
			for each(var i:* in _partnerALL[lv].partnerVecor)
			{
				return checkSelf(PartnerGroup.getPropertyIn(i, PART_CONFIG_ID));  //已招募过   全部招募
			}
			return false;   //未满足
			function checkSelf(congfigid:int):Boolean
			{
				if(partnerVo != null)
				{
					for (var property:String in partnerVo.Properties) 
					{
						if(int(property))
						{
							if(partnerVo.CheckProperties(property))
							{
								var item:ViewObject	= partnerVo.GetPropertiesEx(property);
								if(item.GetPropertiesEx("ConfigID") == congfigid)
								{
									return true;
								}
							}
						}
					}
				}
				return false;
			}
		}
		
		private function showDisable(mc:MovieClip,level:int):void
		{
			for (var i:int = 0; i < MAX_LEN_PER_REC	; i++) 
			{
				var m:MovieClip	= getHeadByIndex(mc, i);
				m.visible		= false;
			}
			mc[ICON].gotoAndStop(level);
			mc["txt"].visible	= true;
			var strID:String	= check(level) ? "UIString_1000572" : "UIString_1000571";
			mc["txt"].htmlText	= StaticIni.getSwfLangStr(strID);
		}
		
		public function get hasPartnerInvite():Boolean
		{
			if(_bindInitFlag)
				return _hasPartnerInvite;
//			beforeShow();
			if(!MultLoader.getInstance().hasSourceByUrl(ResPath.SWF + "partnerRequest.swf")){
				MultLoader.getInstance().load([ResPath.SWF + "partnerRequest.swf"], true, beforeShow);
			} else {
				beforeShow();
			}
			afterHide();
			return _hasPartnerInvite;
		}
		
		public function get checkGuide():int
		{
			if(hasPartnerInvite)//如果有未招募伙伴，提示招募伙伴；      
			{
				return DieHelpLogic.BUDDY;
			}
			if(MyPropertyLogic.getInstance().isPartnerNotEmbattle)//	如果招募了伙伴但没有布阵，提示布阵；
			{
				return DieHelpLogic.EMBATTLE;
			}
			return -1;
		}
		
		/**
		 *邀请伙伴 
		 * @param configid
		 * 
		 */		
		private function applyRequestPartner(configid:int):void
		{
			_currSelectConfigID = configid;
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_INVITE_PARTNER, int(configid));
		}
		
		/**
		 *添加伙伴  、、意味着 要从显示中删除掉 
		 * @param PropertiesName
		 * @param PropertiesValue
		 * @param data
		 * 
		 */		
		private function OnAddPartner(PropertiesName:String, PropertiesValue:ViewObject, data:*):void
		{
			PropertiesValue.HandlePropertiesEx("isFull",true);
			var level:int			= PartnerGroup.getLevel(PropertiesValue);
			var group:PartnerGroup	= (_partnerALL[level]);
			group.addViewPartner(PropertiesValue);
			if(_currSelectConfigID == int(PropertiesValue.GetProperties("ConfigID"))) //招募后删除 右边
			{
				_proPanel.visible		= false;
				_talkPanel.visible		= false;
				_rolePlayBol			= false;
				_myDis.actorClip.source	= null;
				_myDis.sendBtn.visible	= false;
			}
			updataByGroup(group);
			updateHero();
		}
		
		/**
		 *不做处理
		 * @param PropertiesName
		 * @param PropertiesValue
		 * @param data
		 * 
		 */		
		private function OnRemovePartner(PropertiesName:String, PropertiesValue:ViewObject, data:*):void
		{
			
		}
		
		private function updataByGroup(_data:PartnerGroup):void
		{
			var level:int			= _data.Level;
			var currentMc:MovieClip	= _myDis.mainGroup.getItemByIndex(_partnerLevelShow.indexOf(level));
			updateSingle(_data,currentMc);
		}
		
		/**
		 *铜钱 
		 * @param value
		 * 
		 */		
		public function set money(value:int):void
		{
			_myDis.Text2.htmlText	= StaticIni.getSwfLangStrVar("UIString_1000026",[value]);
		}
		
		/**
		 *声望 
		 * @param value
		 * 
		 */		
		public function set repute(value:int):void 
		{
			_myDis.Text1.htmlText	= StaticIni.getSwfLangStrVar("UIString_1000573",[value]);
		}
		
		private  function getMouseOverHeadMc(mc:MovieClip,e:MouseEvent):MovieClip
		{
			for (var i:int = 0; i < MAX_LEN_PER_REC; i++) 
			{
				var m:MovieClip	= getHeadByIndex(mc, i);
				if(m.contains(e.target as DisplayObject))
					return m;
			}
			return null;
		}
		
		/**
		 *鼠标点击 
		 * @param e
		 * 
		 */		
		private function clickHandle(e:MouseEvent):void
		{
			//邀请
			if(e.currentTarget is NxButton	&&	e.currentTarget.enabled && _clickMcData)
			{
				_isOpenFirst	= false;
				var btn:NxButton	= e.currentTarget as NxButton;
				//英雄伙伴招募时检查招募条件是否满足
				if(_heroClickBol && btn.skin == APPLY_BTN){
					var btndata:Object		= _preHeadMc[MC_DATA];
					var _isApply:Boolean	= checkTask(btndata);
					if(!_isApply){
						NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIString_1000718"));
						return;
					}
				}
				applyRequestPartner(PartnerGroup.getPropertyIn(_clickMcData, PART_CONFIG_ID));
				
				function checkTask(partner:Object):Boolean{
					var b:Boolean;
					var _scene:Scene	= ModelLocator.getInstance().scene;
					if(partner[PART_TASK]	&&	partner[PART_TASK]!="0")
					{
						var arr2:Array	= _scene.GetRecordEx("Task_Completed").recArr
						for each (var ia:Array in arr2) 
						{
							if(ia[0] == int(partner[PART_TASK]))
							{
								return true;
							}
						}
						return false;
					}
					return true;
				}
			} 
			else
			{
				var mc:MovieClip	= e.currentTarget as MovieClip;
				var m:MovieClip		= new MovieClip;
				var data:Object		= {};
				if(mc.parent == _myDis.mainGroup){ //普通伙伴
					_heroClickBol		= false;
					m	= getMouseOverHeadMc(mc, e);
					if(!m)	return;
					var index:int		= int(m.name.charAt(m.name.length - 1));
					data				= mc[MC_DATA][index];
				} else if(mc.parent == _myDis.heroGroup){//英雄伙伴
					_heroClickBol		= true;
					m					= mc;
					data				= mc[MC_DATA];
					var heroState:int	= getHeroStatues(PartnerGroup.getPropertyIn(data, PART_CONFIG_ID));
					_isComeBack			= (heroState != 0) ? true : false;
				}
				if(data == null) return;
				if(!_heroClickBol) {
					var isFull:Boolean = (data is ViewObject)?(data as ViewObject).GetProperties("isFull"):data["isFull"];
					if(!isFull) return;
				}
				//是本人则返回
				if(_rolePlayBol && _clickMcData && _clickMcData == data) return;
				_isOpenFirst	= false;
				if(_preHeadMc) {
					_preHeadMc.gotoAndStop(1);
				}
				m.gotoAndStop(2);
				_preHeadMc					= m;
				_clickMcData				= data;
				//如果是未邀请过的伙伴则播放一堆东西，归队伙伴就不客套了
				rightData					= data;
				actorHalf					= data;
				if(data is ViewObject || (heroState && heroState != 0)){ //归队
					if(_rolePlayBol){
						((_myDis.actorClip.source as MovieClip).getChildAt(0) as MovieClip).stop();
						TweenLite.killTweensOf(_myDis.actorClip);
					}
					if(_moveBol){
						TweenLite.killTweensOf(_proPanel);
						TweenLite.killTweensOf(_talkPanel);
					}
					_myDis.actorClip.source		= null;
					_myDis.actorClip.source 	= ResManager.newResClass( "custSkin_86" ) as MovieClip;
					var urlStr:String = "";
					//加载人物模型
					if(data.hasOwnProperty(PART_HEAD))
					{
						urlStr = ResPath.ACTORS + "npc_" + data[ActorPropertyUI.MODEL] + ".swf";
					}
					else
					{
						urlStr = ResourcesPath.getModel(data as ObjectData);
					}
					SwfLoader.StartLoad(urlStr, null, loadOver);
					function loadOver(mc:DisplayObject,pList:Array):void
					{
						_myDis.actorClip.source	= mc;
					}
//					_myDis.actorClip.source 	= ResourcesPath.getModel(data as ObjectData);
					_myDis.sendBtn.visible		= true;
					_myDis.actorClip.x			= _actorPoint.x;
					_myDis.actorClip.y			= _actorPoint.y;
					_proPanel.x					= _proAimPoint.x;
					_proPanel.y					= _proAimPoint.y;
					_proPanel.visible			= true;
					_talkPanel.x				= _talkAimPoint.x;
					_talkPanel.y				= _talkAimPoint.y;
					_talkPanel.visible			= true;
					_myDis.actorClip.addLoadedEvent(
						function loadOver():void
						{
							actorClick(null);
						},Event.COMPLETE);
					_myDis.actorClip.mouseChildren 	= _myDis.actorClip.mouseEnabled = _myDis.actorClip.buttonMode = true;
					_rolePlayBol				= false;
				} else {
					actoraction			= data;
				}
				if(_heroClickBol){
					if(heroState == 0) { //可以招募
						btnLab(APPLY_BTN);
						btnEnable(data);
					} else if (heroState == 1) { //已招募
						_myDis.sendBtn.visible 	= false;
					} else if (heroState == 2) { //离队
						btnLab(COME_BACK_BTN);
						_myDis.sendBtn.enabled	= true;
						_myDis.sendBtn.filters	= [];
					}
				} else {
					btnLab(data is ViewObject ? COME_BACK_BTN : APPLY_BTN);
					btnEnable(data);
				}
			}
			
			function btnLab(str:String):void
			{
				_myDis.sendBtn.mouseEnabled	= false;
				_myDis.sendBtn.skin		= str;
			}
			function btnEnable():void
			{
				var errStr:String	= applyCondition(data);
				if(!errStr)
				{
					_myDis.sendBtn.enabled	= true;
					_myDis.sendBtn.filters	= [];
				}
				else
				{
					_myDis.sendBtn.enabled	= false;
					_myDis.sendBtn.filters	= [FilterUtil.GrayColorFilter];
				}
			}
			/**
			*能否申请 
			* @return 
			* 
			*/		
			function applyCondition(arr:Object):String
			{
				if(arr is ViewObject) return "";
				var moneyNeed:int	=	arr[PART_MONEY]
				if(arr[PART_PEER] > _model.scene.Role.GetPropertiesEx("Repute")){
					return PART_PEER;
				}
				if(moneyNeed >	_model.scene.Role.getGoldCoin()){
					return PART_MONEY;
				}
				if(arr[PART_NEED_LEVEL] > _model.scene.Role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE)){
					return PART_NEED_LEVEL;
				}	
				return "";
			}
		}
		
		/**
		 *获取英雄伙伴状态 
		 * @param configID
		 * @return 
		 * 未招募， 已招募， 离队
		 */		
		private function getHeroStatues(configID:int):int
		{
			var state:int = 0;
			var view:View	= _model.scene.GetView(View.VIEWPORT_PARTNER);
			view.getDataForEach(function (key:Object,value:Object):void
			{
				var viewobj:ViewObject	= value as ViewObject;
				if(viewobj && viewobj.GetProperties(PART_CONFIG_ID) == configID)
				{
					var peer:int	= PartnerGroup.getPeer(viewobj);
					_heroPartner[peer].addViewPartner(viewobj);
					state = 1;
				}
			}
			)
		
			view	= _model.scene.GetView(View.VIEWPORT_RETIRE_PARTNER);
			view.getDataForEach(function (key:Object,value:Object):void
			{
				var viewobj:ViewObject	= value as ViewObject
				if(viewobj && viewobj.GetProperties(PART_CONFIG_ID) == configID)
				{
					var peer:int	= PartnerGroup.getPeer(viewobj);
					_heroPartner[peer].addRetirePartner(viewobj);
					state = 2;
				}
			}
			)
			return state;
		}
		
		/**
		 *设置右边信息 
		 * @param data
		 * 
		 */		
		private function set rightData(data:Object):void
		{
			if(_proPanel.numChildren > 1){
				var len:int	= _proPanel.numChildren - 1;
				for(var i:int = 0; i < len; i++){
					_proPanel.removeChildAt(_proPanel.numChildren - 1);
				}
			}
			if(!data)	return ;
			var	plist:Array		= [];
			var _nameLab:NxLabel = new NxLabel;
			_nameLab.x		= 25;
			_nameLab.y		= 15;
			_proPanel.addChild(_nameLab);
			var _proText:NxText = new NxText;
			_proText.x		= 25;
			_proText.y		= 45;
			_proText.width = 150;
			_proPanel.addChild(_proText);
//			if(!_heroClickBol){
				var _partnerApplyLevel:int	= getPartnerInfo(objTranfer(PartnerGroup.getPropertyIn(data, PART_CONFIG_ID)))[PART_NEED_LEVEL];
				_nameLab.htmlText = StaticIni.getSwfLangStr(PartnerGroup.getPropertyIn(data, PART_CONFIG_ID)) + "(" + StaticIni.getSwfLangStr("PartnerApplyLevel_" + _partnerApplyLevel) + ")"
//			} else {
//				_nameLab.htmlText = StaticIni.getSwfLangStr(PartnerGroup.getPropertyIn(data, PART_CONFIG_ID)) + "(英雄伙伴)";
//			}
			
			var strMc:MovieClip = setProValue(int(objTranfer(PartnerGroup.getPropertyIn(data, PART_STR))), 1);//外功
			_proPanel.addChild(strMc);
			
			var ingMc:MovieClip	= setProValue(int(objTranfer(PartnerGroup.getPropertyIn(data, PART_ING))), 2);//内功
			_proPanel.addChild(ingMc);
			
			var staMc:MovieClip	= setProValue(int(objTranfer(PartnerGroup.getPropertyIn(data, PART_STA))), 3);//体魄
			_proPanel.addChild(staMc);
			
			plist.push(GameDefine.PART_PROFTYPE(objTranfer(PartnerGroup.getPropertyIn(data, PART_GANG))));
			var  s:String		= StaticIni.getSwfLangStr(objTranfer(PartnerGroup.getPropertyIn(data, PART_SKILL)));
			plist.push(s);
			plist.push((GameDefine.GET_SKILL_DES(int(objTranfer(PartnerGroup.getPropertyIn(data, PART_SKILL))))));
			
			s		= StaticIni.getSwfLangStrVar("UIString_1000443", plist);
			plist	= [];
			var _needGold:int = 0;
			var _needPeer:int = 0;
			var _needLevel:int = 0;
			if(!_heroClickBol || !_isComeBack){
				_needGold = PartnerGroup.getPropertyIn(data, PART_MONEY);
				_needPeer = PartnerGroup.getPropertyIn(data, PART_PEER);
				_needLevel = PartnerGroup.getPropertyIn(data, PART_NEED_LEVEL);
			}
			plist.push(objTranfer(getColor(_needGold, _model.scene.Role.getGoldCoin())));
			plist.push(objTranfer(getColor(_needPeer, _model.scene.Role.GetPropertiesEx("Repute"))));
			plist.push(objTranfer(getColor(_needLevel, _model.scene.Role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE))))
			
			_proText.htmlText	= s + "\n" + "\n" + StaticIni.getSwfLangStrVar("stringinvite_001", plist);
			
			function objTranfer(obj:*):String
			{
				if(!obj){
					return 0 + "";
				}
				return obj;
			}
			function getColor(needcount:int, nowCount:int):String
			{
				return _tip.getColorHtml(needcount + "", needcount > nowCount ? "ff0000" : "");
			}
		}
		
		/**
		 *设置属性值 
		 * @param value
		 * @param index
		 * 生命，外功，内功，体魄
		 */		
		private function setProValue(value:int, index:int):MovieClip
		{
			var _proValueMc:MovieClip 	= new MovieClip;
			var _proValueLab:NxLabel	= new NxLabel;
			var _proValueClip:MovieClip	= new MovieClip;
			_proValueClip				= ResManager.newResClass("Partner_ProValue") as MovieClip;
			_proValueClip.y				= 6;
			var _width:Number = 0;
			if(value <= 150) {
				_width					= Math.floor((value / PRO_BASE_VALUE) * 75) * 4;
			} else if(value > 150 && value <= 300){
				_width					= Math.floor((150 / PRO_BASE_VALUE) * 75) * 4;
				_width					+=  Math.floor(((value - 150) / PRO_BASE_VALUE) * 75) * 2;
			} else if(value > 300 && value <= 600){
				_width					= Math.floor((150 / PRO_BASE_VALUE) * 75) * 4;
				_width					+= Math.floor((150 / PRO_BASE_VALUE) * 75) * 2;
				_width					+=  Math.floor(((value - 300) / PRO_BASE_VALUE) * 75);
			}  else {
				_width					= Math.floor((150 / PRO_BASE_VALUE) * 75) * 4;
				_width					+= Math.floor((150 / PRO_BASE_VALUE) * 75) * 2;
				_width					+= Math.floor((300 / PRO_BASE_VALUE) * 75);
				_width					+=  Math.floor(((value - 600) / PRO_BASE_VALUE) * 75) * 0.5;
			}
			_proValueClip.width			= _width;
			_proValueLab.htmlText		= String(value);
			_proValueLab.x				= _proValueClip.width + 8;
			
			_proValueMc.addChild(_proValueClip);
			_proValueMc.addChild(_proValueLab);
			_proValueMc.x				= _proPointArr[index].x;
			_proValueMc.y				= _proPointArr[index].y;
			return _proValueMc;
		}
		
		/**
		 *人物模型 
		 * @param obj
		 * 
		 */		
		private function set actoraction(obj:Object):void
		{
			var data:ObjectData 		= obj as ObjectData;
			//初始人物位置和模型
			if(_rolePlayBol){
				((_myDis.actorClip.source as MovieClip).getChildAt(0) as MovieClip).stop();
			}
			initUI();
			var _runOver:Boolean	= false;
			var urlStr:String = "";
			//加载人物模型
			if(data)
			{
				urlStr = ResourcesPath.getModel(data);
			}
			else
			{
				urlStr = ResPath.ACTORS + "npc_" + obj[ActorPropertyUI.MODEL] + ".swf";
			}
			SwfLoader.StartLoad(urlStr, null, loadOver);
			function loadOver(mc:DisplayObject,pList:Array):void
			{
				_myDis.actorClip.source = mc;
				if(!_runOver){
					((_myDis.actorClip.source as MovieClip).getChildAt(0) as MovieClip).gotoAndPlay(PlayerActionFlag.Run);
				} else {
					((_myDis.actorClip.source as MovieClip).getChildAt(0) as MovieClip).gotoAndPlay(PlayerActionFlag.Wait);	
					_myDis.actorClip.mouseChildren 	= _myDis.actorClip.mouseEnabled = _myDis.actorClip.buttonMode = true;
					_myDis.sendBtn.visible		= true;
				}
				_rolePlayBol			= true;
				
			}
			//跑动时不可点击，到了位置才可以点击
			_myDis.actorClip.mouseChildren = _myDis.actorClip.mouseEnabled = _myDis.actorClip.buttonMode = false;
			
			//让他跑
			TweenLite.to(_myDis.actorClip, 1, {x:_actorPoint.x, y:_actorPoint.y, onComplete:
				function callBack():void
				{
					_runOver	= true;
					//跑完了先待机
					if((_myDis.actorClip.source != _defaultSkin)){
						((_myDis.actorClip.source as MovieClip).getChildAt(0) as MovieClip).gotoAndPlay(PlayerActionFlag.Wait);	
					}
					moveProPanel();
					moveTalkPanel();
				},ease:Linear.easeNone});
		}
		
		/**
		 *属性面板移动 
		 * 
		 */		
		private function moveProPanel():void
		{
			_proPanel.visible			= true;
			TweenLite.to(_proPanel, 0.3, {x:_proAimPoint.x, y:_proAimPoint.y, onComplete:
				function callBack():void
				{
					
				},ease:Linear.easeNone});
		}
		
		/**
		 *会话面板移动 
		 * 
		 */		
		private function moveTalkPanel():void
		{
			_talkPanel.visible			= true;
			_moveBol					= true;
			TweenLite.to(_talkPanel, 0.3, {x:_talkAimPoint.x, y:_talkAimPoint.y, onComplete:
				function callBack():void
				{
					_moveBol			= false;
					actorClick(null);
					_myDis.actorClip.mouseChildren 	= _myDis.actorClip.mouseEnabled = _myDis.actorClip.buttonMode = true;
					_myDis.sendBtn.visible		= true;
				},ease:Linear.easeNone});
		}
		
		/**
		 *初始化界面 
		 * 
		 */		
		private function initUI():void
		{	
			_proPanel.x					= _proSpPoint.x;
			_proPanel.y					= _proSpPoint.y;
			_proPanel.visible			= false;
			
			_talkPanel.x				= _talkPanelPoint.x;
			_talkPanel.y				= _talkPanelPoint.y;
			_talkPanel.visible			= false;
			
			_myDis.sendBtn.visible		= false;
			
			_myDis.actorClip.x			= _actorInitPoint.x;
			_myDis.actorClip.y			= _actorInitPoint.y;
			_myDis.actorClip.source		= null;
			_defaultSkin				= ResManager.newResClass( "custSkin_86" ) as MovieClip;
			_myDis.actorClip.source 	= _defaultSkin;
			
			if(_moveBol){
				TweenLite.killTweensOf(_proPanel);
				TweenLite.killTweensOf(_talkPanel);
			}
		}
		
		/**
		 *点击当前人物模型 
		 * 
		 */		
		private function actorClick(e:Event):void
		{
			if((_myDis.actorClip.source as MovieClip) && ((_myDis.actorClip.source as MovieClip).getChildAt(0) as MovieClip))
			{
				((_myDis.actorClip.source as MovieClip).getChildAt(0) as MovieClip).gotoAndPlay(PlayerActionFlag.Magic);
			}
		}
		
		/**
		 *人物半身像 
		 * @param obj
		 * 
		 */		
		private function set actorHalf(obj:Object):void
		{
			if(_talkPanel.numChildren > 1){
				var len:int	= _talkPanel.numChildren - 1;
				for(var i:int = 0; i < len; i++){
					_talkPanel.removeChildAt(_talkPanel.numChildren - 1);
				}
			}
			var _halfMc:NxClip	= new NxClip;
			ResourcesPath.getHalfPic(PartnerGroup.getPropertyIn(obj, PART_HALF), _halfMc);
			_halfMc.x			= -115;
			_halfMc.y			= 35;
			_halfMc.scaleX		= 0.65;
			_halfMc.scaleY		= 0.65;
			_talkPanel.addChild(_halfMc);
			var _storyMc:NxClip = new NxClip;
			_storyMc.source		= ResManager.newResClass("Partner_Story") as MovieClip;
			_storyMc.x			= 65;
			_storyMc.y			= 20;
			_talkPanel.addChild(_storyMc);
			var _storyTxt:NxText = new NxText;
			_storyTxt.x			= 25;
			_storyTxt.y			= 45;
			_storyTxt.width		= 150;
			_storyTxt.htmlText	= StaticIni.getSwfLangStr("Des_" + PartnerGroup.getPropertyIn(obj, PART_CONFIG_ID));
			_talkPanel.addChild(_storyTxt);
		}
		
		/**
		 *划过 
		 * @param e
		 * 
		 */		
		private function rollOver(e:MouseEvent):void
		{
			var mc:MovieClip = e.currentTarget as MovieClip;
			//主伙伴
			if(mc.parent == _myDis.mainGroup){
				var m:MovieClip	= getMouseOverHeadMc(mc, e);
				if(!m)	return;
				m.gotoAndStop(2);
				//英雄
			} else if (mc.parent == _myDis.heroGroup) {
				mc.gotoAndStop(2)
			}
		}
		
		/**
		 *移出 
		 * @param e
		 * 
		 */		
		private function rollOut(e:MouseEvent):void
		{
			var mc:MovieClip = e.currentTarget as MovieClip;
			//主伙伴
			if(mc.parent == _myDis.mainGroup){
				var m:MovieClip	= getMouseOverHeadMc(mc, e);
				if(!m)	return;
				m.gotoAndStop(1);
				//英雄
			} else if (mc.parent == _myDis.heroGroup) {
				mc.gotoAndStop(1)
			}
		}
		
		/**
		 *往左翻 
		 * @param e
		 * 
		 */		
		private function preBtnHandler(e:MouseEvent):void
		{
			if(_myDis.mainGroup.x >= 125) return;
			var _page:int = _pageNow -1;
			if(_page < 1 || _moveGroupBol) return;
			_pageNow = _page;
			_myDis.pageLab.htmlText	= _pageNow + "/" + _allPage;
			_moveGroupBol	= true;
			_myDis.mainGroup.mouseEnabled = _myDis.mainGroup.mouseChildren = false;
			TweenLite.to(_myDis.mainGroup, 0.3, {x:_myDis.mainGroup.x	+ 330, y:481, onComplete:
				function callBack():void
				{
					_pageNowX	= _myDis.mainGroup.x;
					_myDis.mainGroup.mouseEnabled = _myDis.mainGroup.mouseChildren = true;
					_moveGroupBol = false;
				},ease:Linear.easeNone});
			setLeftRightBtn();
		}
		
		/**
		 *往右翻 
		 * @param e
		 * 
		 */		
		private function nexBtnHandler(e:MouseEvent):void
		{
			if(_myDis.mainGroup.x + 330 - 330 >= 125 + 330) return;
			var _page:int = _pageNow + 1;
			if(_page > _allPage || _moveGroupBol) return;
			_pageNow = _page;
			_myDis.pageLab.htmlText	= _pageNow + "/" + _allPage;
			_moveGroupBol	= true;
			_myDis.mainGroup.mouseEnabled = _myDis.mainGroup.mouseChildren = false;
			TweenLite.to(_myDis.mainGroup, 0.3, {x:_myDis.mainGroup.x	- 330, y:481, onComplete:
				function callBack():void
				{
					_pageNowX	= _myDis.mainGroup.x;
					_myDis.mainGroup.mouseEnabled = _myDis.mainGroup.mouseChildren = true;
					_moveGroupBol = false;
				},ease:Linear.easeNone});
			setLeftRightBtn();
		}
		
		/**
		 *设置左右按钮状态 
		 * 
		 */		
		private function setLeftRightBtn():void
		{
			if(_allPage <= 1){
				_myDis.preBtn.enabled	= false;
				_myDis.nexBtn.enabled	= false;
			} else {
				if(_pageNow == _allPage){
					_myDis.preBtn.enabled	= true;
					_myDis.nexBtn.enabled	= false;
				} else if(_pageNow == 1){
					_myDis.preBtn.enabled	= false;
					_myDis.nexBtn.enabled	= true;
				} else {
					_myDis.preBtn.enabled	= true;
					_myDis.nexBtn.enabled	= true;
				}
			}
		}
		
		/**
		 *移动伙伴 
		 * @param e
		 * 
		 */		
		private function mouseDownHandler(e:MouseEvent):void
		{
			if(!(e.currentTarget	is Sprite)) return;
			if(_moveGroupBol) return;
			if(_allPage == 1) return;
			//先获取鼠标位置
			_pageNowX			= _myDis.mainGroup.x;
			_mouseClickPoint.x	= int(_myDis.mouseX);
			_mouseClickPoint.y	= int(_myDis.mouseY);
			_myDis.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
			StageInfo.uiSpace.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
		}
		
		/**
		 *移动 
		 * @param e
		 * 
		 */		
		private function onMove(e:MouseEvent):void
		{
			//先获取鼠标位置
			_mouseMovePoint.x	= int(_myDis.mouseX);
			_mouseMovePoint.y	= int(_myDis.mouseY);
			//获取鼠标移动方向  差值大于0则向左移
			var _Dvalue:Number	= _mouseClickPoint.x - _mouseMovePoint.x;
			dircetion 			= (_Dvalue > 0);
			if(dircetion){ //往左移即往右翻
				if(_pageNow == _allPage) return;
				_myDis.mainGroup.x = _pageNowX - _Dvalue;
				if(Math.abs(_myDis.mainGroup.x - _pageNowX) > 330){
					_pageNow ++;
					_myDis.pageLab.htmlText	= _pageNow + "/" + _allPage;
					mouseUpHandler(null);
				}
			} else {
				if(_pageNow == 1) return;
				_myDis.mainGroup.x = _pageNowX + Math.abs(_Dvalue);
				if(Math.abs(_myDis.mainGroup.x - _pageNowX) > 330){
					_pageNow --;
					_myDis.pageLab.htmlText	= _pageNow + "/" + _allPage;
					mouseUpHandler(null);
				}
			}
			e.updateAfterEvent();
		}
		
		/**
		 *移动伙伴 
		 * @param e
		 * 
		 */		
		private function mouseUpHandler(e:MouseEvent):void
		{
			_myDis.removeEventListener(MouseEvent.MOUSE_MOVE, onMove);
			StageInfo.uiSpace.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
			//判断在第几页
			var _Dvalue:Number	= _myDis.mainGroup.x - _pageNowX;
			if(int(_myDis.mouseX) <= 0 || int(_myDis.mouseX) >= 912){
				_moveGroupBol	= true;
				TweenLite.to(_myDis.mainGroup, 0.3, {x:_pageNowX, y:481, onComplete:
					function callBack():void
					{
						_pageNowX	= _myDis.mainGroup.x;
						_moveGroupBol = false;
					},ease:Linear.easeNone});
				return;
			}
			//翻页
			if(Math.abs(_Dvalue) >= 330){
				//往右翻
				if(dircetion){
					_moveGroupBol	= true;
					TweenLite.to(_myDis.mainGroup, 0.3, {x:_pageNowX - 330, y:481, onComplete:
						function callBack():void
						{
							_pageNowX	= _myDis.mainGroup.x;
							_moveGroupBol = false;
						},ease:Linear.easeNone});
				} else {
					_moveGroupBol	= true;
					TweenLite.to(_myDis.mainGroup, 0.3, {x:_pageNowX + 330, y:481, onComplete:
						function callBack():void
						{
							_pageNowX	= _myDis.mainGroup.x;
							_moveGroupBol = false;
						},ease:Linear.easeNone});
				}
			} else if(Math.abs(_Dvalue) > 0 && Math.abs(_Dvalue) < 330){
				_moveGroupBol	= true;
				TweenLite.to(_myDis.mainGroup, 0.3, {x:_pageNowX, y:481, onComplete:
					function callBack():void
					{
						_pageNowX	= _myDis.mainGroup.x;
						_moveGroupBol = false;
					},ease:Linear.easeNone});
			}
			setLeftRightBtn();
		}
	}
}

import engine.data.ModelLocator;
import engine.data.RoleVo;
import engine.data.Scene;
import engine.data.ViewObject;
import engine.newUi.ActorPropertyUI;
import engine.newUi.PartnerRequestLogic;
import engine.newUi.PartnerRequestNewLogic;

import newx.BaseObject;
import newx.com.config.StaticIni;

/**
 *同一品级的伙伴群组 
 * @author yanghr
 * 
 */
class PartnerGroup
{
	/**
	 *特殊处理  某些伙伴在接任务之后出现   无视其他条件 
	 */		
	public static  var CurrentAcceptTable:Object,
						CurrentAcceptPartner:Object	= new Object;
	
	public static function getLevel(viewobj:ViewObject):int
	{
		if(viewobj.CheckProperties(LEVEL))
			return viewobj.GetProperties(LEVEL);
		return StaticIni.getIniObj(viewobj.GetPropertiesEx(CONFIGID))[LEVEL];
	}
	public static function getPeer(viewobj:ViewObject):int
	{
		if(viewobj.CheckProperties(PEER))
			return viewobj.GetProperties(PEER);
		return StaticIni.getIniObj(viewobj.GetPropertiesEx(CONFIGID))[PEER];
	}
	public static function getPropertyIn(partner:Object,propertyname:String):*
	{
		if(partner is BaseObject)
		{
			return (partner as BaseObject).GetProperties(propertyname)
		}
		return partner[propertyname];
	}
	/** 
	 *品级属性名 
	 */	
	private  static  const LEVEL:String	= PartnerRequestNewLogic.PART_NEED_LEVEL;
	private const TASK:String				= PartnerRequestNewLogic.PART_TASK;
	private static const CONFIGID:String	= PartnerRequestNewLogic.PART_CONFIG_ID;
	private static const PEER:String		= PartnerRequestNewLogic.PART_PEER;
	
	private var _level:int
	/**
	 *品级 
	 */	
	public function get Level():int
	{
		return _level
	}
	public function PartnerGroup(level:int)
	{
		_level	= level;
	}
	/**
	 *配置表数据 
	 */	
	private var partnerVec:Array		= [];
	/**
	 *上阵伙伴数据 
	 */	
	private var partnerViewObj:Object	= {};
	/**
	 *归队伙伴数据 
	 */	
	private var partnerExObj:Object	= {};
	
	public function get partnerVecor():Array
	{
		return partnerVec;
	}
	/**
	 *得到显示数组 
	 * @return 
	 * 
	 */	
	public function getShowPartners():Array
	{
		var arr:Array		= [];
		var checkType:int	= checkGroup();
		if(checkType == 1)
		{
			var showArr:Array	= [];
			//把可以显示的对象 再检查任务是否完成  能就显示
			for each (var ii:Object in partnerVec) 
			{
				
				if(checkTask(ii))
				{
					ii["isFull"] = true;
				}
				else
				{
					ii["isFull"] = false;
				}
//				ii["isFull"] = true;
//				if(checkisAccepted(ii))
//				{
//				}
//				else
//				{
//					ii["isFull"] = false;
//				}
				showArr.push(ii);
			}
			return showArr;
		}
		else
		{
			
			for each (var i:Object in partnerVec) 
			{
		
				var id:int		= getPropertyIn(i,CONFIGID);
				if(partnerViewObj.hasOwnProperty(id))
				{
					continue;
				}
				if(partnerExObj.hasOwnProperty(id))
				{
					arr.push(partnerExObj[id]);
					continue;
				}
				if(checkTask(i))
				{
					i["isFull"] = true;
				}
				else
				{
					i["isFull"] = false;
				}
//				if(checkTask(i))
//				{
					arr.push(i);
//				}
//					i["isFull"] = false;
			}
		}
		//是否需要排序？？
		return arr;
	}
	/**
	 * 往组里添加  
	 * @param partner
	 * 
	 */	
	public function addConfigPartner(partner:Object):void
	{
		if(checkLevel(partner))
		{
			if(partnerVec.indexOf(partner) == -1)
			{
				partnerVec.unshift(partner)
			}
			
		}
	}
	/**
	 * 
	 * @param partner
	 * 
	 */	
	public function addViewPartner(partner:ViewObject):void
	{
		if(checkLevel(partner))
		{
			partnerViewObj[getPropertyIn(partner,CONFIGID)]	=	partner;
		}
	}
	public function addRetirePartner(partner:ViewObject):void
	{
		if(checkLevel(partner))
		{
			partnerExObj[getPropertyIn(partner,CONFIGID)]	=	partner;
		}
	}
	/**
	 *检查是否符合显示该群组的条件 
	 * @return 
	 * 
	 */	
	public function checkGroup():int
	{
//		trace("当前品阶："+this.Level);
		var _role:RoleVo=ModelLocator.getInstance().scene.Role;
		//伙伴等级需求
		var lvl:int		= _role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE);
		var needLv:int	= int(StaticIni.getIniVar("PartnerGradeNeedLevel", "PartnerGradeNeedLevel_" + Level));
		var roleLv:int	= _role.getPlayerLevel();
		if(Level > (lvl + 1))
		{
			return 0;//完全不显示
		}
//		else if(roleLv < needLv)
//		{
//			return 0;//完全不显示
//		}
		else if(Level == (lvl + 1))
		{
			return 1//显示头像但不能邀请
		}
		return 2;//可以邀请
	}
	/**
	 * 
	 //主线任务需求
	 * @param partner
	 * @return 
	 * 
	 */	
	public function checkTask(partner:Object):Boolean
	{
		var b:Boolean;
		var _scene:Scene	= ModelLocator.getInstance().scene;
		if(getPropertyIn(partner,TASK)	&&	getPropertyIn(partner,TASK)!="0")
		{
			var arr2:Array	= _scene.GetRecordEx("Task_Completed").recArr
			for each (var ia:Array in arr2) 
			{
				if(ia[0] == int(getPropertyIn(partner,TASK)))
				{
					return true
				}
			}
			return false;
		}
		return true;
	}
	/**
	 *检查是否属于接受任务显示条件 
	 * @param partner
	 * @return 
	 * 
	 */	
	public function checkneedAccept(partner:Object):Boolean
	{
		return (CurrentAcceptPartner.hasOwnProperty(getPropertyIn(partner,CONFIGID)))
	}
	/**
	 *检查接受任务条件满足 
	 * @param partner
	 * @return 
	 * 
	 */	
	public function checkisAccept(partner:Object):Boolean
	{
		var _scene:Scene	= ModelLocator.getInstance().scene;
		var id:String		= CurrentAcceptPartner[getPropertyIn(partner,CONFIGID)]
		if(id	&&	id!="0")
		{
			var arr2:Array	= _scene.GetRecordEx("Task_Accepted").recArr
			for each (var ia:Array in arr2) 
			{
				if(ia[0] == int(id))
				{
					return true
				}
			}
		}
		return false;
	}
	/**
	 *检查任务完成条件满足   待定
	 * @param partner
	 * @return 
	 * 
	 */	
	public function checkisAccepted(partner:Object):Boolean
	{
		var _scene:Scene	= ModelLocator.getInstance().scene;
		var id:String		= getPropertyIn(partner,TASK);   //检查需要完成的任务
		if(id == "0")  //不需要任务
		{
			return true;
		}
		else if(id	&&	id != "0")
		{
			var arr2:Array =_scene.GetRecordEx("Task_Completed").recArr       
			for each (var ia:Array in arr2) 
			{
				if(ia[0] == int(id))
				{
					return true
				}
			}
		}
		return false;
	}
	/**
	 *检查伙伴品级是不是群组所对应的品级 
	 * @param partner
	 * @return 
	 * 
	 */	
	public function checkLevel(partner:Object):Boolean
	{
		if(partner is ViewObject)
			return getLevel(partner as ViewObject) == Level
		return partner[LEVEL] == Level;
	}
	/**
	 *是否可以邀请这一品级 
	 */	
	public function get useAble():Boolean 
	{ 
		return Boolean(checkGroup()); 
	}
	/**
	 *重置服务器数据 
	 * 
	 */	
	public function resetServerdata():void
	{
		partnerViewObj	=	{};
		partnerExObj	=	{}//new Vector.<ViewObject>;
	}
}